package org.beetl.json;

import java.util.ArrayList;
import java.util.List;

/**
 * 描述了序列化规则一个loc:action
 * @author xiandafu
 *
 */
public abstract class Location {
	Location parent = null;
	String locName = "";
	List<Location> children = new ArrayList<Location>();
	LocationAction action = null;	
	public Location getParent(){
		return parent;
	}
//	public Location getLocation(Class type,String field){
//		for(Location a:children){
//			if(a.match(type, field)){
//				return a;
//			}
//		}
//		if(parent!=null){
//			return parent.getLocation(type, locName+"."+field);
//		}
//		return null;
//		
//	}
	
	public LocationAction getAction() {
		return action;
	}
	public void setAction(LocationAction action) {
		this.action = action;
	}
	
	public void addLocation(Location loc){
		if(children==null){
			children = new ArrayList<Location>();
		}
		children.add(loc);
	}
	public abstract boolean match(Class type, String field);
	
	
}
